<!DOCTYPE html>
<html>
<head>

	<title></title>
	<style type="text/css">
		*{
			padding: 0;
			margin: 0;
		}
	</style>
</head>
<body>
	<canvas id="canvas" width="500" height="300" style="border: 1px solid #ccc;"></canvas>

	<script type="text/javascript">
		
		var canvas = document.getElementById("canvas");
		var ctx = canvas.getContext("2d");

		ctx.beginPath();
		ctx.moveTo(20,20);
		ctx.lineTo(200,20);
		ctx.lineTo(120,120);
		ctx.closePath(); // draws last line of the triangle
		ctx.stroke();

		ctx.clearRect(10, 10, 100, 100);

	</script>
</body>
</html>